"use strict";
// 类型检查机制
// TypeScript 编译器在做类型检查时，所秉承的一些原则，以及表现出的一些行为。
//作用： 辅助开发，提升开发效率
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
// 1,类型推断
// 2,类型兼容性
// 3,类型保护
// 1,类型推断
var a = 1;
var b = [1, null];
var c = function (x) {
    if (x === void 0) { x = 1; }
    return x + 1;
};
// let foo = {} as Foo
// foo.bar = 1
var foo = {
    bar: 1
};
// 2,类型兼容性
// 当一个类型Y可以被赋值给另一个类型X时，我们就可以说类型X兼容Y
// X兼容Y: X(目标类型)=Y(源类型)
var s = 'a';
var x1 = { a: 1, b: 2 };
var y1 = { a: 1, b: 2, c: 3 };
x1 = y1;
function hof(handler) {
    return handler;
}
//1)参数个数
var handler1 = function (a) { };
hof(handler1);
var handler2 = function (a, b, c) { };
// hof(handler2)
//可选参数和剩余参数
var a1 = function (p1, p2) { };
var b1 = function (p1, p2) { };
var c1 = function () {
    var args = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        args[_i] = arguments[_i];
    }
};
// a1 = b1
// a1 = c1
// b1 = c1
// b1 = a1
// c1 = a1
// c1 = b1
//2）参数类型
var handler3 = function (a) { };
var p3d = function (point) { };
var p2d = function (point) { };
p3d = p2d;
// p2d = p3d
//3) 返回值类型
var f = function () { return ({ name: 'alice' }); };
var g = function () { return ({ name: 'alice', location: 'beijing' }); };
f = g;
// g = f
// function overload(a: number, b: number): number;
//枚举类型兼容性
var fruit;
(function (fruit) {
    fruit[fruit["apple"] = 0] = "apple";
    fruit[fruit["banana"] = 1] = "banana";
})(fruit || (fruit = {}));
var color;
(function (color) {
    color[color["red"] = 0] = "red";
    color[color["yellow"] = 1] = "yellow";
})(color || (color = {}));
var fruit1 = 3;
// let color1 = color.red = fruit1.apple
// 类的兼容性
var A11 = /** @class */ (function () {
    function A11(p, q) {
        this.id = 1;
        this.name = '';
    }
    return A11;
}());
var B11 = /** @class */ (function () {
    function B11(p) {
        this.id = 2;
        this.name = '';
    }
    B11.s = 1;
    return B11;
}());
var aa = new A11(1, 2);
var bb = new B11(1);
// aa = bb
// bb=aa
var C11 = /** @class */ (function (_super) {
    __extends(C11, _super);
    function C11() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return C11;
}(A11));
var cc = new C11(1, 2);
aa = cc;
cc = aa;
var obj1;
var obj2;
// obj1 = obj2
// 结构之间兼容： 成员少的兼容成员多的
// 函数之间兼容： 参数多的兼容参数少的
